Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typing docs: Improve the intro to each section #105901

Merged
merged 1 commit into from
Jun 18, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jun 18, 2023

This PR splits off the hopefully-less-controversial parts of #105827 :-)


📚 Documentation preview 📚: https://cpython-previews--105901.org.readthedocs.build/

Comment on lines -26 to +28
This module provides runtime support for type hints. The most fundamental
support consists of the types :data:`Any`, :data:`Union`, :data:`Callable`,
:class:`TypeVar`, and :class:`Generic`. For a specification, please see
:pep:`484`. For a simplified introduction to type hints, see :pep:`483`.
This module provides runtime support for type hints. For the original
specification of the typing system, see :pep:`484`. For a simplified
introduction to type hints, see :pep:`483`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Union is "soft-deprecated"; Callable is deprecated; following PEP-695, we prefer for people not to instantiate TypeVars directly or to inherit from Generic directly. I feel like this list doesn't serve much purpose anymore, so it's better to just delete it.

Also, describe PEP-484 as the "original specification" rather than "the specification". The typing system has evolved a lot since then.

Comment on lines -50 to +60
For a quick overview of type hints, refer to
`this cheat sheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_.
`"Typing cheat sheet" <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_
A quick overview of type hints (hosted at the mypy docs)

The "Type System Reference" section of https://mypy.readthedocs.io/ -- since
the Python typing system is standardised via PEPs, this reference should
broadly apply to most Python type checkers, although some parts may still be
specific to mypy.
"Type System Reference" section of `the mypy docs <https://mypy.readthedocs.io/en/stable/index.html>`_
The Python typing system is standardised via PEPs, so this reference
should broadly apply to most Python type checkers. (Some parts may still
be specific to mypy.)

The documentation at https://typing.readthedocs.io/ serves as useful reference
for type system features, useful typing related tools and typing best practices.
`"Static Typing with Python" <https://typing.readthedocs.io/en/latest/>`_
Type-checker-agnostic documentation written by the community detailing
type system features, useful typing related tools and typing best
practices.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No huge changes here, this is mostly to improve the Sphinx rendering of the links in the .. seealso box

Comment on lines -659 to -674
.. note::

This module defines several deprecated aliases to pre-existing
standard library classes. These were originally included in the typing
module in order to support parameterizing these generic classes using ``[]``.
However, the aliases became redundant in Python 3.9 when the
corresponding pre-existing classes were enhanced to support ``[]``.

The redundant types are deprecated as of Python 3.9 but no
deprecation warnings are issued by the interpreter.
It is expected that type checkers will flag the deprecated types
when the checked program targets Python 3.9 or newer.

The deprecated types will be removed from the :mod:`typing` module
no sooner than the first Python version released 5 years after the release of Python 3.9.0.
See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
Copy link
Member Author

@AlexWaygood AlexWaygood Jun 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this note down so it's immediately above the section where nearly all the deprecated things are.

Some deprecated things (typing.Callable, typing.Tuple) are in the "Special Forms" section rather than the "Deprecated aliases" section. But I still think this note makes more sense immediately above the "Deprecated aliases" section.

@AlexWaygood
Copy link
Member Author

@miss-islington
Copy link
Contributor

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@AlexWaygood AlexWaygood deleted the typing-docs-improve branch June 18, 2023 23:54
@miss-islington
Copy link
Contributor

Sorry, @AlexWaygood, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 4426279a4399158027a1145cff1c4c92424bf5b5 3.11

@bedevere-bot
Copy link

GH-105902 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label Jun 18, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 18, 2023
(cherry picked from commit 4426279)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this pull request Jun 19, 2023
…05902)

typing docs: Improve the intro to each section (GH-105901)
(cherry picked from commit 4426279)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit to AlexWaygood/cpython that referenced this pull request Jun 19, 2023
@bedevere-bot
Copy link

GH-105903 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 19, 2023
AlexWaygood added a commit that referenced this pull request Jun 19, 2023
)

typing docs: Improve the intro to each section (#105901)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants